VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Frm_Ecal 
   Caption         =   "ECal"
   ClientHeight    =   3300
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5520
   OleObjectBlob   =   "Frm_Ecal.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "Frm_Ecal"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd__ECal_Cal_Click()
    
    Dim i As Integer, j As Integer
    Dim id As Integer
    
    Dim MeasPath() As String
    Dim Command() As String
    Dim chs() As Integer
    Dim allCh As Integer
    Dim UChs As Integer
    allCh = Frm_Main.HaveCh
    Dim bntState As Boolean
    bntState = bntStandard.Value
    Unload Me
    
    For i = 0 To StateNum - 1
        id = -1
        id = GetID(stateName(i))
        If id = -1 Then
            MsgBox "Can't find State File"
            Exit Sub
        End If
        'MeasPath = DevConf(id).MeasPath
        'get Chs and Commands
        ReDim chs(0)
        Call ChsCommands(stateName(i), chs, Command, MeasPath)
        MyENA.ClearError
        'Call State
        CallState stateName(i)
        'have not chs date
        'this for old version
        If chs(0) = 0 Then
            If Len(MeasPath(0)) > 0 Then
                MsgBox "The Cal " + MeasPath(0) + " path,Please Link calibration!"
            End If
            'send Command
            If Len(Command(0)) > 0 Then
            If LCase(Command(0)) <> "null" Then
                Call SerialComBaseModule.OpenComPortPar(Frm_Main.MatrixSerialPort, Frm_Main.MatrixSerialPar) '.OpenComPort ("COM1")
                Call SerialComBaseModule.MixString2ByteSend(Command(0))
                DelayTime 500
                SerialComBaseModule.CloseComPort
            End If
            End If
            'connect ok
            While (MyENA.ECalPath = False)
                temp = MsgBox("Continue?", vbYesNo)
                If temp = vbNo Then
                    Exit Sub
                End If
            Wend
            MyENA.ECalStartSingle
            If bntState = False Then
                Call MyENA.SetDisplayEnable(True)
            End If
            MyENA.SaveState stateName(i)
        Else
            UChs = UBound(chs)
            For j = 0 To UChs
                'send Command
                MsgBox "The Cal " + MeasPath(j) + " path,Please Link calibration!"
                If Len(Command(j)) > 0 Then
                If LCase(Command(j)) <> "null" Then
                    Call SerialComBaseModule.OpenComPortPar(Frm_Main.MatrixSerialPort, Frm_Main.MatrixSerialPar) '.OpenComPort ("COM1")
                    Call SerialComBaseModule.MixString2ByteSend(Command(j))
                    DelayTime 500
                    SerialComBaseModule.CloseComPort
                End If
                End If
                'connect ok
                While (MyENA.ECalPath = False)
                    temp = MsgBox("Continue?", vbYesNo)
                    If temp = vbNo Then
                        Exit Sub
                    End If
                Wend
                Call MyENA.ECalStartMulti(chs(j))
                If bntState = False Then
                    Call MyENA.SetDisplayEnable(True)
                End If
            Next j
            MyENA.SaveState stateName(i)
        End If
    Next i
    MsgBox "ECal OK!"
    
End Sub
Sub MulEcal()

End Sub
Private Sub Cmd_ECal_Exit_Click()
    Unload Me
End Sub

Private Sub UserForm_Initialize()

    For i = 0 To StateNum - 1
        List_ECal.AddItem stateName(i)
        List_ECal.SELected(i) = True
    Next i
    
End Sub

Function GetMeasPath(stateName As Integer) As String
    
    Dim u As Integer
    Dim i As Integer
    u = UBound(DevConf)
    GetMeasPath = ""
    GetMeasPath = DevConf(stateName).MeasPath
    
End Function

